﻿<%@ Page Language="c#" CodeBehind="CustomerInputForOCV.aspx.cs" AutoEventWireup="false"
    Inherits="BEGDC.CC.Web.Common.CustomerInputForOCV" %>

<%@ OutputCache Location="None" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Customer Input</title>
    <base target="_self" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link href="../css/global.css" rel="stylesheet" type="text/css" />
    <link href="../css/style_fu.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .hidden-item
        {
            display: none;
        }
    </style>

    <script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="../JS/checkform.js"></script>

    <script type="text/javascript" src="../JS/common.js"></script>

    <script language="javascript" type="text/javascript">
        //        var flag = 0;
        //        var lastObj;

        //        function CancelSelect(obj) {
        //            if (flag == 0) {
        //                lastObj = obj;
        //                flag += 1;
        //            }
        //            else {
        //                if (lastObj.id != obj.id) {
        //                    lastObj.checked = false;
        //                    lastObj = obj;
        //                }
        //            }
        //            
        //        }

        function test(obj) {
            var id = obj.id;
            var objs;
            if (id != " ") {
                var objs = obj.children;
            }
            document.getElementById("tbCustomerName").value = objs[1].innerText;
            document.getElementById("tbTitle").value = objs[2].innerText;
            document.getElementById("tbCompany").value = objs[3].innerText;
            document.getElementById("rbGiftNeed_1").checked = false;
            document.getElementById("rbEntertainmentNeed_1").checked = false;
            document.getElementById("rbGiftNeed_0").checked = false;
            document.getElementById("rbEntertainmentNeed_0").checked = false;
            $("#customer-id").val(objs[8].innerText);

            if (objs[6].innerText >= 5 || objs[7].innerText >= 3) {
                alert("The number of gifts or entertainment exceeds the limit.\n 此人送礼、娱乐次数超过上限了! ");
                document.getElementById("rbGiftNeed_1").checked = true;
                document.getElementById("rbEntertainmentNeed_1").checked = true;
                document.getElementById("rbGiftNeed").disabled = true;
                document.getElementById("rbEntertainmentNeed").disabled = true;
            }
            else {
                document.getElementById("rbGiftNeed").disabled = false;
                document.getElementById("rbEntertainmentNeed").disabled = false;
            }
        }

        $(function() {
            $('.tbody')
            .bind("click", function() {
                $('.tbody').removeClass('trhover');
                $('.tbody td input:checked').checked = false;
                $(this).addClass('trhover');
                $(this).children().first().children().first().attr("checked", "checked");
            });
        })

        $(function() {
            $('#Btn_Save').bind("click", function() {
                var alertStr = "";
                if (document.getElementById("rbGiftNeed_0").checked == false && document.getElementById("rbGiftNeed_1").checked == false) {
                    alertStr = "Please select Yes or No in IsNeedGift.\n 请选择是否需要送礼! \n";
                }
                if (document.getElementById("rbEntertainmentNeed_0").checked == false && document.getElementById("rbEntertainmentNeed_1").checked == false) {
                    alertStr += "Please select Yes or No in IsNeedEntertainment. \n 请选择是否需要娱乐!";
                }
                if (alertStr != "") {
                    alert(alertStr);
                    event.returnValue = false;
                    return false;
                }

                if ($("#tbCustomerName").attr("value") == "" && $("#tbCompany").attr("value") == "") {
                    alert("Please select the CIS customer. \n 请选择查询后的CIS客户! ");
                    event.returnValue = false;
                    return false;
                }

                var str = $("#tbMyCustomers").attr("value");
                if (str != null && str != "") {
                    var selectedRow = $('#customer-id').val();
                    if (selectedRow != "") {
                        if (str.indexOf("," + selectedRow + ",") < 0) {
                            var bool = confirm("The customer you selected is not in your sales area. Do you want to continue ? \n 您选择的客户不属于您的销售区域，是否继续？");
                            if (bool) {
                                return true;
                            }
                            else {
                                event.returnValue = false;
                                return false;
                            }
                        }
                    }
                }
                else {
                    var bool = confirm("The customer you selected is not in your sales area. Do you want to continue ? \n 您选择的客户不属于您的销售区域，是否继续？");
                    if (bool) {
                        return true;
                    }
                    else {
                        event.returnValue = false;
                        return false;
                    }
                }
            });
        })
    </script>

</head>
<body>
    <%-- <div class="text" id="popupcalendar">
    </div>--%>
    <h3 class="ev-header-section">
        &nbsp;Customer Infomation (客户信息)</h3>
    <form id="Form1" method="post" runat="server">
    <table cellspacing="0" cellpadding="0" width="100%" border="0">
        <tr class="ev-row2">
            <td>
                <div class="formbox5">
                    <span class=" float_lft width200">Customer Name (客户姓名):</span> <span class=" float_lft padding_lft20">
                        <asp:TextBox ID="tbSearchName" CssClass="TEXTBOX" runat="server" MaxLength="20"></asp:TextBox>
                    </span><span class=" float_lft padding_lft20">Customer Title (客户职务):</span> <span
                        class=" float_lft padding_lft20">
                        <asp:TextBox ID="tbSearchTitle" CssClass="TEXTBOX" runat="server" MaxLength="20"></asp:TextBox>
                    </span>
                </div>
                <div class="formbox">
                    <span class=" float_lft  width200">Customer Company (客户公司):</span> <span class=" float_lft padding_lft20">
                        <asp:TextBox ID="tbSearchCompany" CssClass="TEXTBOX" runat="server" MaxLength="20"></asp:TextBox>
                    </span><span class=" float_lft padding_lft20">
                        <asp:ResourceButton ID="ibtnSearch" runat="server" Text="Search" CssClass="btn" ToolTip="SearchTips" />
                    </span>
                </div>
            </td>
        </tr>
    </table>
    <table width="100%">
        <%-- <tr class="ev-row2">
            <td>
                &nbsp;&nbsp;<span>Customer Name</span>
                <asp:TextBox ID="tbSearchName" CssClass="TEXTBOX" runat="server" MaxLength="20"></asp:TextBox>
                &nbsp;&nbsp;<span> Customer Title</span>
                <asp:TextBox ID="tbSearchTitle" CssClass="TEXTBOX" runat="server" MaxLength="20"></asp:TextBox>
                &nbsp;&nbsp;<span> Customer Company</span>
                <asp:TextBox ID="tbSearchCompany" CssClass="TEXTBOX" runat="server" MaxLength="20"></asp:TextBox>
                &nbsp;&nbsp;<asp:Button ID="ibtnSearch" runat="server" Text="Search" CssClass="btn" />
            </td>
        </tr>--%>
        <%--<tr>
            <td valign="middle" width="100%" colspan="2" height="10">
                &nbsp;
            </td>
        </tr>--%>
        <tr class="ev-row2">
            <td>
                <asp:DataGrid ID="DG_CustomerList" runat="server" PagerStyle-Visible="False" PageSize="4"
                    AllowPaging="True" AutoGenerateColumns="False" CssClass="tablestyle">
                    <AlternatingItemStyle></AlternatingItemStyle>
                    <ItemStyle CssClass="tbody"></ItemStyle>
                    <HeaderStyle CssClass="thead"></HeaderStyle>
                    <Columns>
                        <asp:TemplateColumn>
                            <ItemTemplate>
                                <asp:RadioButton ID="CB_CIS" runat="server"></asp:RadioButton>
                            </ItemTemplate>
                        </asp:TemplateColumn>
                        <asp:BoundColumn DataField="Name" HeaderText="Name<br />客户姓名"></asp:BoundColumn>
                        <asp:BoundColumn DataField="Title" HeaderText="Title<br />职务"></asp:BoundColumn>
                        <asp:BoundColumn DataField="Company" HeaderText="Company<br />公司"></asp:BoundColumn>
                        <asp:BoundColumn DataField="Effects" HeaderText="Effects<br />效果" Visible="false">
                            <ItemStyle Width="150px"></ItemStyle>
                        </asp:BoundColumn>
                        <asp:BoundColumn DataField="Country" HeaderText="Country<br />国家"></asp:BoundColumn>
                        <asp:BoundColumn DataField="Region" HeaderText="Region <br />销售区域"></asp:BoundColumn>
                        <asp:BoundColumn Visible="False" DataField="Gender" HeaderText="Gender"></asp:BoundColumn>
                        <asp:BoundColumn DataField="EntertainmentCount" HeaderText="Entertainment Count <br/> 本年度娱乐次数">
                        </asp:BoundColumn>
                        <asp:BoundColumn DataField="GiftCount" HeaderText="Gifts Count <br/> 本年度送礼次数" />
                        <asp:BoundColumn DataField="CustomerID" HeaderText="CustomerID" ItemStyle-CssClass="hidden-item customer-id"
                            HeaderStyle-CssClass="hidden-item"></asp:BoundColumn>
                    </Columns>
                    <PagerStyle Visible="False"></PagerStyle>
                </asp:DataGrid>
            </td>
        </tr>
        <tr class="ev-row2">
            <td class="padding5" align="right">
                &nbsp;&nbsp;
                <asp:ImageButton ID="btnPageFirst" runat="server" ImageUrl="../images/pg_first_inact.gif"
                    ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp;
                <asp:ImageButton ID="btnPagePrev" runat="server" ImageUrl="../images/pg_pre_inact.gif"
                    ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp;
                <asp:ImageButton ID="btnPageNext" runat="server" ImageUrl="../images/pg_next_inact.gif"
                    ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp;
                <asp:ImageButton ID="btnPageLast" runat="server" ImageUrl="../images/pg_last_inact.gif"
                    ImageAlign="AbsMiddle"></asp:ImageButton>&nbsp; &nbsp;&nbsp;
            </td>
        </tr>
        <%--   <tr class="ev-row2" style="display: none">
            <td class="val">
                <asp:Label ID="lbSalesCustomer" Text=" 该客户不在您的销售范围中(说明)：" ForeColor="Red" runat="server"
                    Style="display: none"></asp:Label>
                <br />
                <asp:TextBox ID="tbSalesCustomerExplain" runat="server" TextMode="MultiLine" MaxLength="50"
                    Style="display: none"></asp:TextBox>
            </td>
        </tr>--%>
    </table>
    <input type="hidden" id="customer-id" />
    <table width="100%">
        <tr class="ev-row2">
            <td colspan="2" class="val">
            </td>
        </tr>
        <tr class="ev-row2">
            <td class="title">
                <span class="Star">*</span> Customer Name:<br />
                客户姓名
            </td>
            <td class="val">
                <asp:TextBox ID="tbCustomerName" CssClass="TEXTBOX" runat="server" MaxLength="200"
                    Width="300px"></asp:TextBox>
            </td>
        </tr>
        <tr class="ev-row2">
            <td class="title">
                <span class="Star">*</span>Customer Company:<br />
                客户公司
            </td>
            <td class="val">
                <asp:TextBox ID="tbCompany" CssClass="TEXTBOX" runat="server" MaxLength="200" Width="300px"></asp:TextBox>
            </td>
        </tr>
        <tr class="ev-row2">
            <td class="title">
                Customer Title:<br />
                客户职务
            </td>
            <td class="val">
                <asp:TextBox ID="tbTitle" CssClass="TEXTBOX" runat="server" MaxLength="200" Width="300px"></asp:TextBox>
            </td>
        </tr>
        <tr class="ev-row2">
            <td class="title">
                <span class="Star">*</span>Is Need Gift:<br />
                是否需要送礼
            </td>
            <td class="val">
                <asp:RadioButtonList ID="rbGiftNeed" runat="server" Width="88px" RepeatDirection="Horizontal">
                    <asp:ListItem Value="1">Yes</asp:ListItem>
                    <asp:ListItem Value="0">No</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr class="ev-row2">
            <td class="title">
                <span class="Star">*</span>Is Need Entertainment:<br />
                是否需要安排娱乐项目
            </td>
            <td class="val">
                <asp:RadioButtonList ID="rbEntertainmentNeed" runat="server" Width="88px" RepeatDirection="Horizontal">
                    <asp:ListItem Value="1">Yes</asp:ListItem>
                    <asp:ListItem Value="0">No</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr class="ev-row2">
            <td class="title">
                Remark:<br />
                备注
            </td>
            <td class="val">
                <asp:TextBox ID="tbRemark" CssClass="COMMENT" runat="server" TextMode="MultiLine"
                    MaxLength="500"></asp:TextBox>
            </td>
        </tr>
        <tr class="ev-row2">
            <td colspan="2" class="val" style="color: Red">
                &nbsp;&nbsp;Please input customer information in CIS firstly if they can not be
                found,or you are not allowed to submit the application in normal case.<br />
                &nbsp;&nbsp;请在只填写客户姓名的情况下使用查询功能;若客户在CIS中不存在, 请尽快到CIS系统中补充该客户信息(注:所填信息需与CCS中完全相同)
            </td>
        </tr>
        <tr class="ev-row2">
            <td colspan="2" class="padding5 ac">
                <asp:TextBox ID="tbReturnValue" Style="display: none" runat="server"></asp:TextBox>
                <asp:TextBox ID="tbMyCustomers" Style="display: none" runat="server"></asp:TextBox>
                <asp:TextBox ID="tbIsExist" Style="display: none" runat="server">3</asp:TextBox>
                <asp:ResourceButton ID="Btn_Save" runat="server" check="true" class='btn' Text="OK"
                    ToolTip="OKTips" />
                <asp:ResourceButton ID="Btn_Close" runat="server" check="false" class='btn' Text="Close"
                    ToolTip="CloseTips" />
            </td>
        </tr>
        <tr class="ev-row2">
            <td colspan="2" class="val">
                <asp:DropDownList ID="ddlResponsibility" Visible="false" runat="server">
                </asp:DropDownList>
                <asp:DropDownList ID="ddlAffects" runat="server" Visible="false">
                </asp:DropDownList>
            </td>
        </tr>
    </table>
    </form>

    <script language="javascript" type="text/javascript">
        function OnSave() {
            if (document.Form1.tbIsExist.value == 3) {
                if (!window.confirm("The customer is not in CIS. Are you sure to save?")) { event.returnValue = false; }
            }
            else {
                if (!window.confirm(SaveInfo)) { event.returnValue = false; }
            }
        }

        function OnClose() {
            window.close();
            window.returnValue = 'close';
        }
        
        
    </script>

</body>
</html>
